Possible loss of precision / [type] cannot be dereferenced
Posted
by Samuel
on Stack Overflow
See other posts from Stack Overflow
or by Samuel
Published on 2010-05-20T12:29:47Z
Indexed on
2010/05/20
12:30 UTC
Read the original article
Hit count: 219
I have been looking around a lot but i simply can't find a nice solution to this...
Point mouse = MouseInfo.getPointerInfo().getLocation();
int dx = (BULLET_SPEED*Math.abs(x - mouse.getX()))/
(Math.abs(y - mouse.getY()) + Math.abs(x - mouse.getX()))*
(x - mouse.getX())/Math.abs(x - mouse.getX());
In this constellation i get: Possible loss of precision, when i change e.g (x - mouse.getX())
to (x - mouse.getX()).doubleValue()
it says double cannot be dereferenced, when i add intValue() somewhere it says int cannot be dereferenced. What's my mistake?
[x, y are integers | BULLET_SPEED is a static final int
]
Thanks!
© Stack Overflow or respective owner